from django.db import models
from rest_framework.serializers import ModelSerializer

# Create your models here.


# 用户
class QyMember(models.Model):
    openid = models.CharField('openid', max_length=30,blank=True)
    unionid = models.CharField('unionid', max_length=30,blank=True)
    avatar = models.ImageField('头像',upload_to='static/member_icon',blank=True)
    age = models.IntegerField('年龄',blank=True)
    nickname = models.CharField('昵称',blank=True,max_length=56)
    profession = models.CharField('职业',blank=True,max_length=255)
    phonenum = models.BigIntegerField('电话',blank=True)
    balance = models.CharField('余额',default='0.00',max_length=16)
    add_time = models.CharField('创建时间', max_length=20)

    def __str__(self):
        return self.nickname

    class Meta:
        db_table = 'qy_member'
        verbose_name = '用户'
        verbose_name_plural = verbose_name


# 实体类
class MemberSerializer(ModelSerializer):

    class Meta:
        model = QyMember
        fields = ('id','avatar','nickname','phonenum')



class MemberAll(ModelSerializer):
    class Meta:
        model = QyMember
        fields = '__all__'


